<script type="text/javascript" src="<?=base_url()?>resource/plugins/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="<?=base_url()?>resource/js/layer/layer.js"></script>
<script type="text/javascript" src="<?=base_url()?>resource/js/layer/extend/layer.ext.js"></script>
<script type="text/javascript">
    $(function(){
        trbgmoves('#d3dff2');
    });
    function gotoshow(orderid){
        $('#order').attr('display','block');
        layer.open({
            type: 1,
            title:'产品信息（'+orderid+'）',
            area: ['620px', '470px'], //宽高
            content: $('#order')
        });
        $.post("<?=blang_url('ajax/ajax/GetAliexpressOrder')?>",{'orderid':orderid},function(data){
            var product = JSON.parse(data);
            $('#orderId').val(product.orderId);
            $('#skuInfo').val(product.skuInfo);
            $('#BrandName').val(product.BrandName);
            $('#Model').val(product.Model);
            $('#ROM').val(product.ROM);
            $('#Display').val(product.Display);
            $('#Item').val(product.Item);
            $('#Unlock').val(product.Unlock);
            $('#CPU').val(product.CPU);
            $('#Battery').val(product.Battery);
            $('#DisplaySize').val(product.DisplaySize);
            $('#RAM').val(product.RAM);
            $('#description').val(product.description);
            var imgStr='';
            if(product.attachments) {
                var imgArr = JSON.parse(product.attachments);
                for (var i = 0; i < imgArr.length; i++) {
                    imgStr += "<a href='javascript:void(0)' onclick=imgView(\'"+imgArr[i]+"\')>img" + i + "</a>&nbsp;&nbsp;&nbsp;&nbsp;";
                }
            }
            $('#imgList').html(imgStr);
        });
    }
    function upstatus(orderid){
        var ctstatus=$('#'+orderid).val();
        var contact='<?=$this->users['name']?>';
        $.post("<?=blang_url('ajax/ajax/UpdateAeStatus')?>", {
            'orderid': orderid,
            'ctstatus': ctstatus,
            'contact': contact
        }, function (data) {
            var obj=JSON.parse(data);
            $('#tr' + orderid).css('color', obj.color);
            $('#tact'+orderid).text(obj.contact);
            $('#time'+orderid).text(obj.time);
            $('#follow'+orderid).text(parseInt($('#follow'+orderid).text())+1);
        });
    }
    function imgView(src){
        // 图片地址
        var img_url = src;
        // 创建对象
        var imgs = new Image();
        // 改变图片的src
        imgs.src = img_url;
        // 定时执行获取宽高
        var width=0;
        var height=0;
        var check = function(){
            // 只要任何一方大于0
            // 表示已经服务器已经返回宽高
            if(imgs.width>0 || imgs.height>0){
                width=imgs.width;
                height=imgs.height;
                clearInterval(set);
                if(width > 800){
                    width=width*0.8;
                    height=height*0.8;
                    if(width>800){
                        width=width*0.8;
                        height=height*0.8;
                    }
                }
                if(height > 700){
                    height=height*0.8;
                    width=width*0.8;
                    if(height>700){
                        height=height*0.8;
                        width=width*0.8;
                        if(height>700){
                            height=height*0.8;
                            width=width*0.8;
                            if(height>700){
                                height=height*0.8;
                                width=width*0.8;
                                if(height>700){
                                    height=height*0.8;
                                    width=width*0.8;
                                }
                            }
                        }
                    }
                }
                layer.open({
                    type: 1,
                    shade: false,
                    area: [width+'px', height+'px'], //宽高
                    title: false, //不显示标题
                    content: "<img width='"+(width-3)+"' height='"+(height-3)+"' src="+src+">" //捕获的元素
                });
            }
        };
        var set = setInterval(check,40);
    }
</script>
<!--top结束-->
<div class="mian">
    <div class="mian1">
        <div class="mian2">
            <!--left start-->
            <?php $this->load->view('defaults/common/left');?>
            <!--left end-->

            <!--right start-->
            <div class="right" >
                <!--breadcrumb start-->
                <div class="righta"><?=$this->breadcrumb->generateHTML();?>&nbsp; <span style="color: red" id="tishis"><?=$nums?></span></div>
                <!--breadcrumb end-->

                <!-- contents start -->
                <div id="contents">
                    <div id="ct_search">
                        <form action="<?=blang_url('orders/AliExpress/GetAliExpressWarrantyValidList')?>" method="get" name="searchform" >
                            <table id="search_tb">
                                <tr>
                                    <td >
                                        OrderID:<input type="text"  name="orderId">
                                        Name:<input type="text" id="name" name="name">
                                        Country:
                                        <select id="country" name="country">
                                                    <option value=""><?=lang('smtqb')?></option>
                                                    <option value="es">es</option>
                                                    <option value="ru">ru</option>
                                                    <option value="uk">uk</option>
                                                    <option value="us">us</option>
                                                    <option value="de">de</option>
                                        </select>
                                        status:
                                        <select  name="ctstatus1">
                                            <option value=""><?=lang('smtqb')?></option>
                                            <option value="0" ><?=lang('smtwlx')?></option>
                                            <option value="1"  style="color: #ff9a00"><?=lang('smtylx')?></option>
                                            <option value="2"  style="color: #009900"><?=lang('smtkrzjjj')?></option>
                                            <option value="3"  style="color: #0000ff"><?=lang('smtmyjdh')?></option>
                                            <option value="4"  style="color: #ff0000"><?=lang('smtdhbsbr')?></option>
                                            <option value="5"  style="color: #ff33ff"><?=lang('smtzlwtlxmj')?></option>
                                        </select>
                                        <input type="submit" value="<?=lang('smtcx')?>">
                                        &nbsp;<a href="<?=blang_url('orders/AliExpress/ExportAliExpressWarrantyValidData/'.$str)?>">Export Excel</a>
                                    </td>
                                </tr>
                            </table>
                        </form>
                    </div>
                    <div class="ct_content">
                        <table>
                            <thead class="table_thead" >
                            <tr>
                                <th width="20%" ><?=lang('smtsm')?></th>
                                <th width="5%" ><?=lang('smtdh')?></th>
                                <th width="12%" ><?=lang('smtfwkssj')?></th>
                                <th width="5%" ><?=lang('smtgj')?></th>
                                <th width="31%" ><?=lang('smtzt')?></th>
                                <th width="8%" ><?=lang('smtlxr')?></th>
                                <th width="12%" ><?=lang('smtlxsj')?></th>
                                <th width="7%" ><?=lang('smtgjcs')?></th>
                            </tr>
                            </thead>
                            <?PHP foreach($AeList as $Ae):?>
                                <tr style="color: <?=$Ae['color']?>" class="moves" id="tr<?=$Ae['orderId']?>" align="center" ondblclick="gotoshow('<?=$Ae['orderId']?>')">
                                    <td><?=$Ae['name']?></td>
                                    <td><?=$Ae['telephone']?></td>
                                    <td><?=$Ae['serviceStartTime']?></td>
                                    <td><?=$Ae['country']?></td>
                                    <td>
                                        <select id="<?=$Ae['orderId']?>" name="ctstatus2">
                                            <option value="0" <?=$Ae['ctstatus']==0?'selected':''?>><?=lang('smtwlx')?></option>
                                            <option value="1" <?=$Ae['ctstatus']==1?'selected':''?> style="color: #ff9a00"><?=lang('smtylx')?></option>
                                            <option value="2" <?=$Ae['ctstatus']==2?'selected':''?> style="color: #009900"><?=lang('smtkrzjjj')?></option>
                                            <option value="3" <?=$Ae['ctstatus']==3?'selected':''?> style="color: #0000ff"><?=lang('smtmyjdh')?></option>
                                            <option value="4" <?=$Ae['ctstatus']==4?'selected':''?> style="color: #ff0000"><?=lang('smtdhbsbr')?></option>
                                            <option value="5" <?=$Ae['ctstatus']==5?'selected':''?> style="color: #ff33ff"><?=lang('smtzlwtlxmj')?></option>
                                        </select>
                                        <input type="button" value="<?=lang('public_tj')?>" onclick="upstatus('<?=$Ae['orderId']?>')">
                                    </td>
                                    <td id="tact<?=$Ae['orderId']?>"><?=$Ae['contact']?></td>
                                    <td id="time<?=$Ae['orderId']?>"><?=$Ae['ctime']==''?'':date('Y-m-d H:i:s',$Ae['ctime'])?></td>
                                    <td id="follow<?=$Ae['orderId']?>"><?=$Ae['follow_up']?></td>
                                </tr>
                            <?php endforeach;?>
                            <tr><th colspan="8" height="40"><?=$pageshow?></th></tr>
                            </tbody>
                        </table>
                    </div>
                </div>
                <!-- contents end -->
            </div>
            <!--right end-->
            <div class="clear"></div>
        </div>
    </div>
</div>
<div id='order' style="display: none;text-align: center;margin-left: 50px;">
    <table style="border: 1px;">
        <tr>
            <td align="right">orderId</td>
            <td align="left" style="padding-left: 20px;"><input id="orderId" size="50"></td>
        </tr>
        <tr>
            <td align="right">BrandName</td>
            <td align="left" style="padding-left: 20px;"><input id="BrandName" size="50"></td>
        </tr>
        <tr>
            <td align="right">Model</td>
            <td align="left" style="padding-left: 20px;"><input id="Model" size="50"></td>
        </tr>
        <tr>
            <td align="right">skuInfo</td>
            <td align="left" style="padding-left: 20px;"><input id="skuInfo" size="50"></td>
        </tr>
        <tr>
            <td align="right">ROM</td>
            <td align="left" style="padding-left: 20px;"><input id="ROM" size="50"></td>
        </tr>
        <tr>
            <td align="right">Display</td>
            <td align="left" style="padding-left: 20px;"><input id="Display" size="50"></td>
        </tr>
        <tr>
            <td align="right">Item</td>
            <td align="left" style="padding-left: 20px;"><input id="Item" size="50"></td>
        </tr>
        <tr>
            <td align="right">Unlock</td>
            <td align="left" style="padding-left: 20px;"><input id="Unlock" size="50"></td>
        </tr>
        <tr>
            <td align="right">CPU</td>
            <td align="left" style="padding-left: 20px;"><input id="CPU" size="50"></td>
        </tr>
        <tr>
            <td align="right">Battery</td>
            <td align="left" style="padding-left: 20px;"><input id="Battery" size="50"></td>
        </tr>
        <tr>
            <td align="right">DisplaySize</td>
            <td align="left" style="padding-left: 20px;"><input id="DisplaySize" size="50"></td>
        </tr>
        <tr>
            <td align="right">RAM</td>
            <td align="left" style="padding-left: 20px;"><input id="RAM" size="50"></td>
        </tr>
        <tr>
            <td align="right">Description</td>
            <td align="left" style="padding-left: 20px;"><textarea id="description" style="width: 378px;height: 100px;"></textarea></td>
        </tr>
        <tr>
            <td align="right">IMG:</td>
            <td align="left" style="padding-left: 20px;" id="imgList"></td>
        </tr>
    </table>
</div>